package com.google.oop2;

/**
 * @author Mucd
 * @Date 2020/12/15
 * @Class Student
 */
public class Student {
    private String name;
    private int age;
    private String sex;

    /**
     * 无参构造方法
     */
    public Student() {
    }

    public Student(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        System.out.println(name+" "+age+" "+sex);
    }

    public String getSex() {
        return name;
    }

    public void setSex(String sex) {
        switch (sex) {
            case "男", "女":
                this.sex = sex;
                break;
            default:
                System.out.println("输入正确的性别");
        }
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public int getAge(int age) {
        return age;
    }

    public void setAge(int age) {
        if (age > -1) {
            this.age = age;
        } else {
            System.out.println("年龄不能小于0");
        }
    }

    public void read() {
        if (name != null && age != 0 && sex != null) {
            System.out.println("Name: " + name + " " + "Age: " + age + " " + "Sex: " + sex);
        } else {
            System.out.println("信息输入有误");
        }
    }
}
